#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
using namespace std;
long arr[105];
int i;
int main()
{
	do {
		cin >> arr[i++];
	} while (arr[i - 1] != 0);
	for (i -= 2; i >= 0; i--) {
		cout << arr[i] << " ";
	}
	return 0;
}